<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>对象</title>
</head>

<body>
    <script>
        var num = 10

        function test() {
            var num = 15
            console.log('this', this)
            console.log('test')
            console.log(num)
            console.log('全局变量num的值', this.num)
        }

        // 输出全局对象
        console.log(this)
        console.log(window)

        // 获取全局变量的值，作为全局对象的属性
        console.log(this.num)
        console.log(window.num)

        // 调用函数，可以调用全局对象的方法
        this.test()
        window.test()
    </script>
</body>

</html>